This calculator stores all its numbers and operators in strings.
It uses the JavaScript eval
function to evaluate these expressions. For example, the
result of eval("2 + 2") is 4.
JavaScript can evaluate any string which uses valid
JavaScript constructs; the statement eval("alert('hello')") is
identical in execution to alert('hello').
Try it out. Tap on the [C] clear button, click
in the text entry field, and delete the zero.
Now type 2 + 2
directly into the Calculator's
answer window and then press the [=] button.
Try typing and evaluating these other expressions.
Remember: [C]lear and erase the zero each time; also
remember that JavaScript is case sensitive.
- 1 * 2 * 3 * 4 * 5
- Math.cos(3.14159)
- alert('hi')